package com.ruoyi.appreciate.rubbing.service.impl;

import com.ruoyi.appreciate.rubbing.domain.Rubbing;
import com.ruoyi.appreciate.rubbing.mapper.RubbingMapper;
import com.ruoyi.appreciate.rubbing.service.IRubbingService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 碑帖欣赏Service业务层处理
 * 
 * @author duanxinli
 * @date 2025-10-10
 */
@Service
public class RubbingServiceImpl implements IRubbingService
{
    @Autowired
    private RubbingMapper rubbingMapper;

    /**
     * 查询碑帖欣赏
     * 
     * @param id 碑帖欣赏主键
     * @return 碑帖欣赏
     */
    @Override
    public Rubbing selectRubbingById(String id)
    {
        return rubbingMapper.selectRubbingById(id);
    }

    /**
     * 查询碑帖欣赏列表
     * 
     * @param rubbing 碑帖欣赏
     * @return 碑帖欣赏
     */
    @Override
    public List<Rubbing> selectRubbingList(Rubbing rubbing)
    {
        return rubbingMapper.selectRubbingList(rubbing);
    }

    /**
     * 新增碑帖欣赏
     * 
     * @param rubbing 碑帖欣赏
     * @return 结果
     */
    @Override
    public int insertRubbing(Rubbing rubbing)
    {
        rubbing.setId(IdUtils.fastUUID());
        rubbing.setCreateDate(DateUtils.getNowDate());
        String username = SecurityUtils.getUsername();
        rubbing.setCreateBy(username);
        rubbing.setSort(0L);
        rubbing.setDelFlag(0L);
        return rubbingMapper.insertRubbing(rubbing);
    }

    /**
     * 修改碑帖欣赏
     * 
     * @param rubbing 碑帖欣赏
     * @return 结果
     */
    @Override
    public int updateRubbing(Rubbing rubbing)
    {
        return rubbingMapper.updateRubbing(rubbing);
    }

    /**
     * 批量删除碑帖欣赏
     * 
     * @param ids 需要删除的碑帖欣赏主键
     * @return 结果
     */
    @Override
    public int deleteRubbingByIds(String[] ids)
    {
        return rubbingMapper.deleteRubbingByIds(ids);
    }

    /**
     * 删除碑帖欣赏信息
     * 
     * @param id 碑帖欣赏主键
     * @return 结果
     */
    @Override
    public int deleteRubbingById(String id)
    {
        return rubbingMapper.deleteRubbingById(id);
    }
}
